<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        body{
            height:3000px;
        }
        .nav{
            width: 800px;
            height:50px;
            background-color: pink;
            position: sticky;
            top: 10px;
            margin: 100px auto;
        }
    </style>
</head>
<body>
    <div class="nav">
        我是导航栏
    </div>
</body>
</html>